home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Interfaces / PInterfaces / UPrinting.p < prev    next >
Encoding:
Text File  |  1990-10-25  |  23.3 KB  |  559 lines  |  [TEXT/MPS ]

  1. {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}
  2. { UPrinting.p }
  3. { Copyright © 1986-1990 by Apple Computer Inc. All rights reserved. }
  4.  
  5. {$IFC UNDEFINED UsingIncludes}
  6. {$SETC UsingIncludes := FALSE}
  7. {$ENDC}
  8.  
  9. {$IFC NOT UsingIncludes}
  10. UNIT UPrinting;
  11.  
  12.     INTERFACE
  13.         {$ENDC}
  14.  
  15.         {$IFC UNDEFINED __UPrinting__}
  16.         {$SETC __UPrinting__ := FALSE}
  17.         {$ENDC}
  18.  
  19.         {$IFC NOT __UPrinting__}
  20.         {$SETC __UPrinting__ := TRUE}
  21.  
  22.         { • Required for this unit's interface. Auto-Include them }
  23.         {$SETC UPrintingIncludes := UsingIncludes}
  24.         {$SETC UsingIncludes := TRUE}
  25.         {$I+}
  26.         {$IFC UNDEFINED __UMacApp__} {$I UMacApp.p} {$ENDC}
  27.  
  28.         {$IFC UNDEFINED UsingDialogs} {$I Dialogs.p} {$ENDC}
  29.         {$IFC NOT qNeedsROM128K}
  30.         {$IFC UNDEFINED UsingPrinting} {$I Printing.p} {$ENDC}
  31.         {$ELSEC}
  32.         {$IFC UNDEFINED UsingPrintTraps} {$I PrintTraps.p} {$ENDC}
  33.         {$ENDC}
  34.         {$SETC UsingIncludes := UPrintingIncludes}
  35.  
  36.         CONST
  37.  
  38.             { Command constants }
  39.             cChangePrinterStyle = 192;                    { Command arising from user's making changes
  40.                                                          in Page Setup... dialog }
  41.             cShowBreaks         = 201;                    { “Show Page Breaks” command }
  42.  
  43.             { Printing-related command numbers which apply only when a view with a non-null PrintHandler
  44.             is in the target chain }
  45.  
  46.             { Dialogs }
  47.             phSpoolPrintDialog    = 257;                    { the dialog shown when printing a file (a
  48.                                                          misnomer - not just when spooled) }
  49.             phFinderPrintDialog = 258;                    { the dialog shown when doing Finder
  50.                                                          Printing; differs from prev. by addition
  51.                                                          of a 'Cancel All Printing' button }
  52.  
  53.             { Alerts }
  54.             phNoPages            = 251;                    { The “no pages within requested range”
  55.                                                          alert }
  56.  
  57.             { Dialogs }
  58.             phWhichDoc            = 261;                    { The “Preparing to print <docname>” dialog
  59.                                                          used during Finder printing }
  60.  
  61.             { Miscellaneous }
  62.             kUsualPages         = MAXINT;                { For methods that take a “pageNumber”
  63.                                                          argument, this value indicates a request
  64.                                                          for a general setting rather than a
  65.                                                          setting customized to one particular page
  66.                                                          }
  67.  
  68.             kNeverInitialized    = MAXINT;                { Pseudo-value for fPrinterDev field of
  69.                                                          TStdPrintHandler; used to trigger an
  70.                                                          initial PrinterChanged call }
  71.  
  72.             kPrintDriverName    = $E000;                { STR resource in System file which contains
  73.                                                          name of the current print driver }
  74.  
  75.         TYPE
  76.  
  77.             PageAreas            = RECORD
  78.                 thePaper:            Rect;                { physical page }
  79.                 theInk:             Rect;                { printable page }
  80.                 theMargins:         Rect;                { top-left positive; bottom-right negative }
  81.                 theInterior:        Rect;                { rect into which view-subset is projected }
  82.                 END;
  83.  
  84.             TStdPrintHandler    = OBJECT (TPrintHandler) { Actually Implements all the features that
  85.                                                           were stubbed out in its ancestor. Basic
  86.                                                           flow of control at print time: Print,
  87.                                                           CheckPrinter, For each page(
  88.                                                           FocusOnBorder, DrawPageInterior,
  89.                                                           FocusOnBorder, AdornPage) are called. }
  90.                 fPageAreas:         PageAreas;            { metrics for printing }
  91.  
  92.                 fPrintExtent:        VRect;                { the part of the view's extent that is to
  93.                                                          be printed by this print handler. The
  94.                                                          default is the entire extent, but it can
  95.                                                          be changed with the method SetAreaToPrint.
  96.                                                          }
  97.  
  98.                 fFixedSizePages:    ARRAY [VHSelect] OF BOOLEAN;
  99.                                                         { Indicates whether pages are fixed size
  100.                                                         horzontally and vertically. }
  101.  
  102.                 fHPrint:            Handle;             { actually of THPrint, a MacPrint type. The
  103.                                                          Print Record is 120 bytes long, and may be
  104.                                                          shared among all PrintHandlers in a
  105.                                                          document or may be unique to each
  106.                                                          PrintHandler, depending on the flag
  107.                                                          TDocument.fSharePrintInfo }
  108.  
  109.                 fPageStrips:        Point;                { For printing a view which will take more
  110.                                                          than one page to print, the view is
  111.                                                          thought of as being divided up by vertical
  112.                                                          and horizontal lines ('page breaks') into
  113.                                                          a checkerboard of 'pages'. A vertical
  114.                                                          column, one page wide, of such pages is
  115.                                                          called a 'vertical page strip', while a
  116.                                                          horizontal row, one page high, of such
  117.                                                          pages is called a 'horizontal page strip'.
  118.                                                          The number of vertical page strips is
  119.                                                          represented by fPageStrips.v, and the
  120.                                                          number of horizontal page strips is
  121.                                                          represented by fPageStrips.h In a typical
  122.                                                          Word Processor application, there is only
  123.                                                          one vertical strip of pages, but many
  124.                                                          horizontal 'strips', each one only one
  125.                                                          page wide. In a graphical application,
  126.                                                          there may be many vertical as well as
  127.                                                          horizontal strips of pages. fPageStrips is
  128.                                                          recomputed by method CalcPageStrips. }
  129.  
  130.                 fStartPage:         INTEGER;            { the page number for the topleftmost corner
  131.                                                          of the view. Normally 1, but can be set to
  132.                                                          any positive value }
  133.  
  134.                 fPrinterDev:        INTEGER;            { MacPrint's device number for printer; use
  135.                                                          this at Print time for getting font
  136.                                                          metrics in device coordinates }
  137.  
  138.                 fLastCheckedPrinter: LONGINT;            { The time that the user's chosen Printer
  139.                                                          and my own idea of printer metrics were
  140.                                                          last known to be in harmony }
  141.  
  142.                 fLastPrinterName:    StringHandle;        { The name of the current printer driver, at
  143.                                                          fLastCheckedPrinter. }
  144.  
  145.                 fPageDirection:     VHSelect;            { Determines how page numbers are to advance
  146.                                                          in a large view which is more than one
  147.                                                          page wide and more than one page high; v
  148.                                                          means page 2 is BELOW page 1; h means it's
  149.                                                          to its RIGHT. Irrelevant if the view is
  150.                                                          only one page wide or only one page high }
  151.  
  152.                 fShowBreaks:        BOOLEAN;            { TRUE iff page breaks should be displayed
  153.                                                          at the moment }
  154.  
  155.                 fFinderSetup:        BOOLEAN;            { whether, during Finder Printing, the 'Page
  156.                                                          Setup' dialog should be presented to the
  157.                                                          user }
  158.  
  159.                 fFinderJobDialog:    BOOLEAN;            { whether, during Finder Printing, the Print
  160.                                                          Job dialog should be presented to the user
  161.                                                          (making it seem like “Print...”) or not
  162.                                                          (making it seem like “Print One”) }
  163.  
  164.                 fSquareDots:        BOOLEAN;            { if TRUE, then in the initial instance, use
  165.                                                          72 x 72 resolution by default on
  166.                                                          ImageWriter; if FALSE, then full 80 x 72
  167.                                                          is used. This flag has no significance if
  168.                                                          the default printer at the time of
  169.                                                          creation of the printHandler is not an
  170.                                                          ImageWriter }
  171.                 fMinimalMargins:    BOOLEAN;            { If TRUE, page margins are maintained such
  172.                                                          that exactly the complete printable area
  173.                                                          of the page is used. }
  174.  
  175.                 fLastStrip:         Point;                { The last strip printed. }
  176.  
  177.                 fLastBreak:         VPoint;             { The coordinates of the last page break. }
  178.  
  179.                 fViewedRect:        VRect;                { The part of the view shown on the
  180.                                                          "current" page. Set by SetPage. }
  181.  
  182.                 fMarginRes:         Point;                { Used when computing margins }
  183.  
  184.                 fPrintDialog:        DialogPtr;            { Used for all printing-related dialogs. ???
  185.                                                          (shouldn't this really be a view (or
  186.                                                          TDialogView if using UDialog) }
  187.                 fPPrPort:            TPPrPort;            { Printer Port in use during printing }
  188.                                 { Initialization/Termination }
  189.                 PROCEDURE TStdPrintHandler.IStdPrintHandler(itsDocument: TDocument;
  190.                                                             itsView: TView;
  191.                                                             itsSquareDots, itsHFixedSize,
  192.                                                             itsVFixedSize: BOOLEAN);
  193.                 { Initializes the printHandler and installs it in the view; if 'itsSquareDots' is
  194.                 TRUE, then a default print record for the ImageWriter world will use square dots
  195.                 ('tall adjusted') rather than rectangular ones; this sacrifices a bit of resolution
  196.                 but ensures that graphics will appear undistorted on the printed page }
  197.  
  198.                 PROCEDURE TStdPrintHandler.Free; OVERRIDE;
  199.                 { If relevant, frees the PrintInfo record and does other cleanup before freeing SELF
  200.                 }
  201.  
  202.                 { Page Strips }
  203.  
  204.                 PROCEDURE TStdPrintHandler.CalcPageStrips(VAR pageStrips: Point); OVERRIDE;
  205.                 { Recalculate the number of strips of pages in each dimension }
  206.  
  207.                 PROCEDURE TStdPrintHandler.CalcViewPerPage(VAR amtPerPage: VPoint); OVERRIDE;
  208.                 { Decide how much view (h and v) normally gets mapped into page interiors }
  209.  
  210.                 FUNCTION TStdPrintHandler.BreakFollowing(vhs: VHSelect;
  211.                                                          prevBreak: VCoordinate;
  212.                                                          VAR automatic: BOOLEAN): VCoordinate;
  213.                     OVERRIDE;
  214.                 { Returns the location of the page break which follows the page break located at
  215.                 'prevBreak', in direction vhs; returns automatic = TRUE if the page-break is
  216.                 thought of as an 'automatic' rather than a 'manual' (user-specified) one. Note that
  217.                 page-breaks in dimension 'v' are drawn as vertical lines, those in dimension 'h' as
  218.                 horizontal lines. Generic support at present is only provided for 'automatic' page
  219.                 breaks; the 'automatic' parameter in BreakFollowing is a hook to allow clients to
  220.                 support manual page breaks as well }
  221.  
  222.                 PROCEDURE TStdPrintHandler.EachBreak(vhs: VHSelect;
  223.                                                      includeLast: BOOLEAN;
  224.                                                      FUNCTION
  225.                                                      DoToBreak(loc: VCoordinate;
  226.                                                                automatic: BOOLEAN): BOOLEAN);
  227.                 { Iterates through all page-breaks in the dimension given by vhs, or until DoToBreak
  228.                 returns true; the trailing edge of the view (i.e., right or bottom edge) is given
  229.                 as the final break if 'includeLast' is TRUE. The function 'DoToBreak' is called
  230.                 once for each page break in the chosen dimension }
  231.  
  232.                 PROCEDURE TStdPrintHandler.GetBreakCoord(vhs: VHSelect;
  233.                                                          whichBreak: INTEGER;
  234.                                                          VAR loc: VCoordinate);
  235.                 { Returns, in 'loc', the coordinate of the 'whichBreak-th' page break in dimension
  236.                 vhs. For example, GetBreakCoord(v, 5, loc) will return, in 'loc', the horizontal
  237.                 coordinate of the vertical line (page-break) which marks the boundary the area of
  238.                 the view which will be mapped into the 4th vertical strip of pages and the area of
  239.                 the view which will be mapped into the 5th vertical strip of pages }
  240.  
  241.                 FUNCTION TStdPrintHandler.PageToStrip(pageNumber: INTEGER): Point;
  242.                 { Returns the horizontal and vertical strip for the given page. }
  243.  
  244.                 FUNCTION TStdPrintHandler.StripToPage(hStrip, vStrip: INTEGER): INTEGER;
  245.                 { Returns the page number for the given page strip. }
  246.  
  247.                 FUNCTION TStdPrintHandler.PointToPageStrip(pointInView: VPoint): Point;
  248.                 { Returns the page strip for a given point in view space. }
  249.  
  250.                 { General Utility }
  251.  
  252.                 PROCEDURE TStdPrintHandler.GetDocName(VAR docName: Str255);
  253.                 { Returns the name of the document being printed, for use in the print dialog. }
  254.  
  255.                 PROCEDURE TStdPrintHandler.DoInMacPrint(PROCEDURE WhatToDo);
  256.                 { If printing code is available, open the Print Driver, then call procedure
  257.                 “WhatToDo”, then close the Print Driver. If printing code not available, does
  258.                 nothing }
  259.  
  260.                 PROCEDURE TStdPrintHandler.OpenPrintShop;
  261.                 { Attempts to open the print shop by calling PrOpen. Signals failure if an error
  262.                 occurs. Called from DoInMacPrint. }
  263.  
  264.                 PROCEDURE TStdPrintHandler.ClosePrintShop;
  265.                 { Closes the print shop by calling PrClose. DOES NOT signal failure if an error
  266.                 occurs, only reports it to the debug window. }
  267.  
  268.                 FUNCTION TStdPrintHandler.MaxPageNumber: INTEGER; OVERRIDE;
  269.                 { Returns the highest page number which would be printed if the user requested that
  270.                 “all pages” be printed }
  271.  
  272.                 PROCEDURE TStdPrintHandler.AdornPage;
  273.                 { Draw things on page # 'aPageNumber' which do not arise from the View but rather
  274.                 from page considerations; examples: Headers and Footers; page numbers; frames drawn
  275.                 around inset text; row and column headers for spreadsheets. }
  276.  
  277.                 PROCEDURE TStdPrintHandler.ChooseSpoolFile(VAR spoolFileName: Str255;
  278.                                                            VAR spoolVRefNum: INTEGER;
  279.                                                            VAR pagesPerSubjob: INTEGER);
  280.                 { Select the filename and volume to use for spooling; default chooses empty string on
  281.                 vol 0, which results in MacPrint's automatically choosing the local Boot volume }
  282.  
  283.                 PROCEDURE TStdPrintHandler.DrawPageInterior;
  284.                 { Make the QuickDraw calls which will result in the 'Interior' of page #
  285.                 'aPageNumber' being drawn. The 'Interior' is those things on the page which arise
  286.                 from drawing the View associated with the PrintHandler }
  287.  
  288.                 PROCEDURE TStdPrintHandler.FocusOnBorder;
  289.                 { Set up GrafPort, clipping, etc., prior to calling AdornPage }
  290.  
  291.                 PROCEDURE TStdPrintHandler.FocusOnInterior; OVERRIDE;
  292.                 { Set up the GrafPort, clipping, etc., prior to calling DrawPageInterior }
  293.  
  294.                 PROCEDURE TStdPrintHandler.LocatePageInterior(pageNumber: INTEGER;
  295.                                                               VAR loc: Point); OVERRIDE;
  296.                 { Determine where to locate the top-left corner of the Interior of the given page
  297.                 nuamber }
  298.  
  299.                 FUNCTION TStdPrintHandler.OneSubJob(subjobFirstPage, subjobLastPage: INTEGER;
  300.                                                     justSpool: BOOLEAN;
  301.                                                     partialJob: BOOLEAN;
  302.                                                     VAR ranOutOfSpace: BOOLEAN;
  303.                                                     VAR lastPageTried: INTEGER;
  304.                                                     VAR proceed: BOOLEAN): TCommand;
  305.                 { Processes one subjob for printing. Where appropriate, a print job is divided
  306.                 automatically into one or more 'subjobs', so that a long document can be printed
  307.                 even if there is very limited spool space available on the disk. This is a
  308.                 generalization of the 'spool-a-page/print-a-page' technique. TStdPrintHandler will
  309.                 use a subjob size as large as can be handled by current conditions, and will only
  310.                 fall back to more subjobs, each of smaller size, if it experiences problems running
  311.                 with a larger subjob size }
  312.  
  313.                 FUNCTION TStdPrintHandler.Print(itsCmdNumber: CmdNumber;
  314.                                                 VAR proceed: BOOLEAN): TCommand; OVERRIDE;
  315.                 { Carries out printing for the print handler. }
  316.  
  317.                 PROCEDURE TStdPrintHandler.PrintPage(aPageNumber: INTEGER);
  318.                 { Print the indicated page }
  319.  
  320.                 PROCEDURE TStdPrintHandler.SetPage(aPageNumber: INTEGER);
  321.                 { Forwards to TView.DoSetInterior and TView.DoSetPageOffset }
  322.  
  323.                 PROCEDURE TStdPrintHandler.SetPageInterior(pageNumber: INTEGER); OVERRIDE;
  324.                 { Responsible for installing the correct values into fPageAreas.theInterior,
  325.                 representing the 'interior' of the page in View coordinates }
  326.  
  327.                 PROCEDURE TStdPrintHandler.SetPageOffset(coord: VPoint); OVERRIDE;
  328.                 { Given the view-coordinate of the top-left-most point of the view which is mapped
  329.                 into the interior of this page, calculate and set the offset for the print code. }
  330.  
  331.                 { Formatting for printing and other Setup methods }
  332.  
  333.                 PROCEDURE TStdPrintHandler.CheckPrinter; OVERRIDE;
  334.                 { Check to see if user has changed printer specifications; if so, react }
  335.  
  336.                 PROCEDURE TStdPrintHandler.InstallMargins(newMargins: Rect;
  337.                                                           areMinimalMargins: BOOLEAN);
  338.                 { Install the (possibly new) margins specified; if 'areMinimalMargins' is TRUE, then
  339.                 the minimal-margins scheme is used; in this scheme, margins are always maintained
  340.                 at exactly the size necessary to have the page Interior coincide exactly with the
  341.                 printable area of the page }
  342.  
  343.                 PROCEDURE TStdPrintHandler.PrinterChanged; OVERRIDE;
  344.                 { After printer specifications have changed, absorb the new metrics and reformat the
  345.                 view if necessary }
  346.  
  347.                 PROCEDURE TStdPrintHandler.RedoPageBreaks; OVERRIDE;
  348.                 { Recalculate the page breaks }
  349.  
  350.                 PROCEDURE TStdPrintHandler.Reset; OVERRIDE;
  351.                 { Reset print record to default }
  352.  
  353.                 PROCEDURE TStdPrintHandler.SetDefaultPrintInfo; OVERRIDE;
  354.                 { Create a PrintInfo record and initialize it to default values }
  355.  
  356.                 PROCEDURE TStdPrintHandler.SetPrintExtent;
  357.                 { Sets the part of the print handler's view that is printed by this print handler, by
  358.                 calling the view's GetPrintExtent. }
  359.  
  360.                 PROCEDURE TStdPrintHandler.SetMargins;
  361.                 { Install the desired page margins }
  362.  
  363.                 PROCEDURE TStdPrintHandler.ValidatePrintRecord(VAR didChange: BOOLEAN);
  364.                 { Make certain that the current Print Record is compatible with the user's current
  365.                 printer choice; 'didChange' is set to TRUE iff the kind of printer changed }
  366.  
  367.                 { Menu Commands }
  368.  
  369.                 FUNCTION TStdPrintHandler.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
  370.                 { Handles 'show page breaks', among others }
  371.  
  372.                 PROCEDURE TStdPrintHandler.DoSetupMenus; OVERRIDE;
  373.                 { Sets up menus for 'show page breaks' and company }
  374.  
  375.                 { Finder Printing }
  376.  
  377.                 FUNCTION TStdPrintHandler.SetupForFinder: BOOLEAN; OVERRIDE;
  378.                 { Sets up the print record for finder printing. If fFinderPageSetup is true, then
  379.                 PosePageSetupDialog is called. If fFinderJobDialog is true, then PoseJobDialog is
  380.                 called. Otherwise, prJobMerge is called to merge the job record from the }
  381.  
  382.                 FUNCTION SetupPrintOne: BOOLEAN;
  383.                 { Sets up the print record for a "print one" type of operation, one where the entire
  384.                 document or view is printed and no job dialog takes place. Returns true if we
  385.                 should proceed. }
  386.  
  387.                 { Screen Feedback }
  388.  
  389.                 PROCEDURE TStdPrintHandler.DrawPrintFeedback(area: Rect); OVERRIDE;
  390.                 { Gateway to all screen feedback related to pagination issues }
  391.  
  392.                 PROCEDURE TStdPrintHandler.DrawPageBreak(vhs: VHSelect;
  393.                                                          whichBreak: INTEGER;
  394.                                                          loc: VCoordinate;
  395.                                                          automatic: BOOLEAN); OVERRIDE;
  396.                 { Draws a page break on the screen. }
  397.  
  398.                 PROCEDURE TStdPrintHandler.InvalPageFeedback;
  399.                 { Invalidates all page-related screen feedback }
  400.  
  401.                 FUNCTION TStdPrintHandler.ShowsOnScreen: BOOLEAN;
  402.                 { Returns TRUE only if the printHandler has an fView which is in an open window. }
  403.  
  404.                 { Dialogs relating to printing }
  405.  
  406.                 FUNCTION TStdPrintHandler.PoseJobDialog: BOOLEAN;
  407.                 { Pose the 'Print Job' dialog }
  408.  
  409.                 FUNCTION TStdPrintHandler.PosePageSetupDialog(VAR proceed: BOOLEAN;
  410.                                                               isUndoable: BOOLEAN): TCommand;
  411.                 { Undertake the 'Page Setup' dialog; return a command object to be performed if
  412.                 relevant }
  413.  
  414.                 PROCEDURE TStdPrintHandler.PosePrintDialog;
  415.                 { Put up the 'Printing in Progress' dialog }
  416.  
  417.                 PROCEDURE TStdPrintHandler.ShowDocBeingPrinted(entering: BOOLEAN);
  418.                 { Put up (or remove) a window whose title is the document's title, because the Print
  419.                 Manager gets the document title from the front window. }
  420.  
  421.                 PROCEDURE TStdPrintHandler.BanishPrintDialog;
  422.                 { Get rid of the print dialog. }
  423.  
  424.                 PROCEDURE TStdPrintHandler.DoPrintIdling;
  425.                 { Print job idle time handler. Handles events in the 'Print Dialogs' which give the
  426.                 user 'Cancel', and, in the case of printing from the Finder, 'Cancel All Printing.
  427.                 }
  428.  
  429.                 PROCEDURE TStdPrintHandler.ChkPrintErr(VAR err: OSErr;
  430.                                                        VAR proceed: BOOLEAN;
  431.                                                        VAR ranOutOfSpace: BOOLEAN);
  432.                 { Checks for a MacPrint error, but only if 'proceed' is TRUE on entry; specially
  433.                 handles one particular error (sets return parameter 'ranOutOfSpace' if error code
  434.                 indicates disk-space problem while saving a spool file). }
  435.  
  436.                 PROCEDURE TStdPrintHandler.PrintSpoolFile(anHPrint: Handle;
  437.                                                           VAR err: OSErr;
  438.                                                           VAR proceed: BOOLEAN);
  439.                 { If printing was spooled by the print-driver then this Method will be called
  440.                 to print the spooled image. }
  441.  
  442.                 PROCEDURE TStdPrintHandler.GetDriverName(VAR driverName: Str255);
  443.                 { Get the name of the current printer driver. }
  444.  
  445.                 { Debugging }
  446.  
  447.                 PROCEDURE TStdPrintHandler.IdentifySoftware; OVERRIDE;
  448.                 { Shows the version of the Printing Unit being used; display is in
  449.                 the Debug window }
  450.  
  451.                 PROCEDURE TStdPrintHandler.Fields(PROCEDURE
  452.                                                   DoToField(fieldName: Str255;
  453.                                                             fieldAddr: Ptr;
  454.                                                             fieldType: INTEGER)); OVERRIDE;
  455.                 { Used by the Inspector and the Debugger to display the contents of this classes
  456.                 fields. }
  457.                 END;
  458.  
  459. {--------------------------------------------------------------------------------------------------}
  460.             TPrintStyleChangeCommand = OBJECT (TCommand) { Used to allow changes made by the user in
  461.                                                           the 'Page Setup...' dialog to be
  462.                                                           undoable. }
  463.  
  464.             { Fields }
  465.  
  466.                 fStdPrintHandler:    TStdPrintHandler;    { Associated print handler }
  467.  
  468.                 fOldHPrint:         Handle;             { The old print record, before the change }
  469.                 fNewHPrint:         Handle;             { The new print record, after the change }
  470.  
  471.                                 { Initialization and Termination }
  472.  
  473.                 PROCEDURE TPrintStyleChangeCommand.IPrintStyleChangeCommand(itsPrintHandler:
  474.                                                                             TStdPrintHandler);
  475.                 { Initializes the print style change command, makes a copy of the old print handle
  476.                 and creates the new one. }
  477.                 PROCEDURE TPrintStyleChangeCommand.Free; OVERRIDE;
  478.                 { Disposes the old and new print handles. }
  479.  
  480.                 { Command Execution }
  481.  
  482.                 PROCEDURE TPrintStyleChangeCommand.DoIt; OVERRIDE;
  483.                 { Calls CheckPrinter, finding it changed will dispatch to views DoPrinterChanged
  484.                 method. }
  485.  
  486.                 PROCEDURE TPrintStyleChangeCommand.UndoIt; OVERRIDE;
  487.                 { Copies the old print handle back and calls CheckPrinter which will in turn call the
  488.                 views DoPrinterChanged method. }
  489.  
  490.                 PROCEDURE TPrintStyleChangeCommand.RedoIt; OVERRIDE;
  491.                 { Copies the new print handle back and calls CheckPrinter which will in turn call the
  492.                 views DoPrinterChanged method. }
  493.  
  494.                 { Debugging }
  495.                 PROCEDURE TPrintStyleChangeCommand.Fields(PROCEDURE
  496.                                                           DoToField(fieldName: Str255;
  497.                                                                     fieldAddr: Ptr;
  498.                                                                     fieldType: INTEGER)); OVERRIDE;
  499.                 { Used by the Inspector and the Debugger to display the contents of this class's
  500.                 fields. }
  501.  
  502.                 END;
  503.  
  504. {--------------------------------------------------------------------------------------------------}
  505.             TPrintCommand        = OBJECT (TNoChangesCommand) { Returned in response to a printing
  506.                                                               request. Doesn't actually do the
  507.                                                               printing itself, but forwards to the
  508.                                                               appropriate handler. }
  509.  
  510.                 fStdPrintHandler:    TStdPrintHandler;    { the associated print handler }
  511.  
  512.                 PROCEDURE TPrintCommand.IPrintCommand(itsCmdNumber: CmdNumber;
  513.                                                       itsStdPrintHandler: TStdPrintHandler);
  514.                 { Initialize the PrintCommand procedurally }
  515.  
  516.                 PROCEDURE TPrintCommand.DoIt; OVERRIDE;
  517.                 { Tell the print handler to print }
  518.  
  519.                 PROCEDURE TPrintCommand.Fields(PROCEDURE
  520.                                                DoToField(fieldName: Str255;
  521.                                                          fieldAddr: Ptr;
  522.                                                          fieldType: INTEGER)); OVERRIDE;
  523.                 { Used by the Inspector and the Debugger to display the contents of this class's
  524.                 fields. }
  525.  
  526.                 END;
  527.  
  528.         VAR
  529.             gBreaksPenState:    PenState;                { penState to used to draw page breaks }
  530.             gCancelAllPrinting: BOOLEAN;                { set to TRUE if during Finder Printing user
  531.                                                          selects “Cancel All” }
  532.             gStdPageMargins:    Rect;                    { "Standard" left, top, right, bottom page
  533.                                                          margins, in screen resolution - one inch
  534.                                                          all round by default }
  535.             gFinderHPrint:        Handle;                 { Used for finder printing, to do PrJobMerge
  536.                                                          when printing more than one document. }
  537.  
  538.             gJobPrintHandler:    TStdPrintHandler;        { The Print Handler in use during printing.
  539.                                                          }
  540.  
  541.             { Initialization }
  542.  
  543.         PROCEDURE InitUPrinting;
  544.         { Call once, at application start-up time. You can interrogate global variable 'gCouldPrint'
  545.         at any time to determine whether printing code is actually accessible }
  546.  
  547.         PROCEDURE InitPrinting;
  548.         { Synonym for InitUPrinting.  Left in for compatibility (2.0) }
  549.  
  550.         PROCEDURE IdleProcForTStdPrintHandler;
  551.         { Procedure whose address is passed to the print job for calling as often as possible.
  552.         Forwards to the DoPrintIdling method of the job's print handler. }
  553.  
  554.         {$ENDC}
  555.  
  556.         {$IFC NOT UsingIncludes}
  557. END.
  558. {$ENDC}
  559.